package org.kiwi.data.enums;

import org.springframework.util.Assert;

/**
 * Created by jack on 16/10/30.
 */
public enum DbType {
    MYSQL("mysql"), ORACLE("oracle"), DB2("db2");

    private String text;

    DbType(String text) {
        this.text = text;
    }

    public String getText() {
        return text;
    }

    public static DbType determineDbTypeByText(String text) {
        Assert.hasText(text, "text is required");

        for (DbType dbType : DbType.values()) {
            if (dbType.getText().equalsIgnoreCase(text))
                return dbType;
        }

        return MYSQL;
    }
}
